package cn.acac.yygh.hosp.controller.admin;

import cn.acac.yygh.model.acl.User;
import cn.acac.yygh.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * 用户登录相关操作
 */
@RestController
@RequestMapping(value = "/admin/user")
@Api(value = "用户操作的控制器")
public class UserController {


    /**
     * 用户登录的验证
     * @param user
     * @return
     * {"code":20000,"data":{"token":"admin-token"}}
     */
    @PostMapping("/login")
    @ApiOperation("用户登录接口")
    public R login(@RequestBody User user){
        // 返回验证成功的信息
        return R.ok().setData("token","admin-token");
    }

    /**
     * 返回用户登录的信息
     * @param token
     * @return
     */
    @GetMapping("/info")
    @ApiOperation("用户信息接口")
    public R info(String token){
        return R.ok()
                .setData("roles","[admin]")
                .setData("introduction","I am a super administrator")
                .setData("avatar","https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2Fb25515c32f0610a2a81ceba529b984e7ddff1dc0232b07-cuBBou_fw658&refer=http%3A%2F%2Fhbimg.b0.upaiyun.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671257232&t=7fc2f215fc1941bbd0a0bbe20886fe13")
                .setData("name","如果你觉得这是我的名字，那就是！");
    }
}
